
import java.util.Vector;
import soot.jimple.toolkits.callgraph.CallGraph;

public class IndexContainer {
	/**
	 * contains all the methods of the project
	 */
	static Vector<IndexMethod> methods;
	
	/**
	 * the cg of the project
	 */
	static CallGraph cg;
	
	/**
	 * the generator of all the indexes
	 */
	static IndexGenerator generator;

	/**
	 * initialize the indexes, after doing this, the indexes are built
	 * 
	 * @param cg2
	 *            the call graph
	 * @param files
	 *            the classNames from the file types_and_compliationUnits.txt
	 */
	public static void init(CallGraph cg2, Vector<String> files) {
		methods = new Vector<IndexMethod>();
		generator = new IndexGenerator(cg2, files);
		cg = cg2;
		System.out.println("start initial indexes for all the classes");
		generator.init();
		methods = generator.getMethods();
		System.out.println("finish building all the indexes");
	}

	/**
	 * get the specific class index according to a given class name
	 * 
	 * @param name
	 *            the name of the class
	 * @return the index index data structure
	 */
	public static IndexMethod getMethod(String name) {
		for (int i = 0; i < methods.size(); i++) {
			if (methods.get(i).getName().equals(name)) {
				return methods.get(i);
			}
		}
		return null;
	}

	@Override
	public String toString() {
		return generator.toString();
	}

	/**
	 * I need a static method to get the output.......
	 * 
	 * @return the output of the indexes
	 */
	public static String getString() {
		return generator.toString();
	}
}
